
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>django.contrib.postgres.indexes &#8212; Django 2.2.12.dev20200304094918 documentation</title>
    <link rel="stylesheet" href="../../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />



 
<script type="text/javascript" src="../../../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../../../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../../index.html">Django 2.2.12.dev20200304094918 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../../../index.html">Home</a>  |
        <a title="Table of contents" href="../../../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../../../genindex.html">Index</a>  |
        <a title="Module index" href="../../../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    <a href="../../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="_modules-django-contrib-postgres-indexes">
            
  <h1>Source code for django.contrib.postgres.indexes</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">django.db.models</span> <span class="k">import</span> <span class="n">Index</span>
<span class="kn">from</span> <span class="nn">django.db.utils</span> <span class="k">import</span> <span class="n">NotSupportedError</span>
<span class="kn">from</span> <span class="nn">django.utils.functional</span> <span class="k">import</span> <span class="n">cached_property</span>

<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
    <span class="s1">&#39;BrinIndex&#39;</span><span class="p">,</span> <span class="s1">&#39;BTreeIndex&#39;</span><span class="p">,</span> <span class="s1">&#39;GinIndex&#39;</span><span class="p">,</span> <span class="s1">&#39;GistIndex&#39;</span><span class="p">,</span> <span class="s1">&#39;HashIndex&#39;</span><span class="p">,</span>
    <span class="s1">&#39;SpGistIndex&#39;</span><span class="p">,</span>
<span class="p">]</span>


<span class="k">class</span> <span class="nc">PostgresIndex</span><span class="p">(</span><span class="n">Index</span><span class="p">):</span>

    <span class="nd">@cached_property</span>
    <span class="k">def</span> <span class="nf">max_name_length</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="c1"># Allow an index name longer than 30 characters when the suffix is</span>
        <span class="c1"># longer than the usual 3 character limit. The 30 character limit for</span>
        <span class="c1"># cross-database compatibility isn&#39;t applicable to PostgreSQL-specific</span>
        <span class="c1"># indexes.</span>
        <span class="k">return</span> <span class="n">Index</span><span class="o">.</span><span class="n">max_name_length</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">Index</span><span class="o">.</span><span class="n">suffix</span><span class="p">)</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">suffix</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">create_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">schema_editor</span><span class="p">,</span> <span class="n">using</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">check_supported</span><span class="p">(</span><span class="n">schema_editor</span><span class="p">)</span>
        <span class="n">statement</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">create_sql</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="n">schema_editor</span><span class="p">,</span> <span class="n">using</span><span class="o">=</span><span class="s1">&#39; USING </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">suffix</span><span class="p">)</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_with_params</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">with_params</span><span class="p">:</span>
            <span class="n">statement</span><span class="o">.</span><span class="n">parts</span><span class="p">[</span><span class="s1">&#39;extra&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;WITH (</span><span class="si">%s</span><span class="s1">) </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span>
                <span class="s1">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">with_params</span><span class="p">),</span>
                <span class="n">statement</span><span class="o">.</span><span class="n">parts</span><span class="p">[</span><span class="s1">&#39;extra&#39;</span><span class="p">],</span>
            <span class="p">)</span>
        <span class="k">return</span> <span class="n">statement</span>

    <span class="k">def</span> <span class="nf">check_supported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_editor</span><span class="p">):</span>
        <span class="k">pass</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="p">[]</span>


<div class="viewcode-block" id="BrinIndex"><a class="viewcode-back" href="../../../../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.BrinIndex">[docs]</a><span class="k">class</span> <span class="nc">BrinIndex</span><span class="p">(</span><span class="n">PostgresIndex</span><span class="p">):</span>
    <span class="n">suffix</span> <span class="o">=</span> <span class="s1">&#39;brin&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">autosummarize</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">pages_per_range</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">pages_per_range</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">pages_per_range</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;pages_per_range must be None or a positive integer&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">autosummarize</span> <span class="o">=</span> <span class="n">autosummarize</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pages_per_range</span> <span class="o">=</span> <span class="n">pages_per_range</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">deconstruct</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">deconstruct</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">autosummarize</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;autosummarize&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">autosummarize</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pages_per_range</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;pages_per_range&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">pages_per_range</span>
        <span class="k">return</span> <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span>

    <span class="k">def</span> <span class="nf">check_supported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_editor</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">schema_editor</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">features</span><span class="o">.</span><span class="n">has_brin_index_support</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">NotSupportedError</span><span class="p">(</span><span class="s1">&#39;BRIN indexes require PostgreSQL 9.5+.&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">autosummarize</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema_editor</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">features</span><span class="o">.</span><span class="n">has_brin_autosummarize</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">NotSupportedError</span><span class="p">(</span><span class="s1">&#39;BRIN option autosummarize requires PostgreSQL 10+.&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">autosummarize</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;autosummarize = </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="s1">&#39;on&#39;</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">autosummarize</span> <span class="k">else</span> <span class="s1">&#39;off&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pages_per_range</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;pages_per_range = </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">pages_per_range</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">with_params</span></div>


<div class="viewcode-block" id="BTreeIndex"><a class="viewcode-back" href="../../../../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.BTreeIndex">[docs]</a><span class="k">class</span> <span class="nc">BTreeIndex</span><span class="p">(</span><span class="n">PostgresIndex</span><span class="p">):</span>
    <span class="n">suffix</span> <span class="o">=</span> <span class="s1">&#39;btree&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">fillfactor</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="o">=</span> <span class="n">fillfactor</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">deconstruct</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">deconstruct</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;fillfactor&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span>
        <span class="k">return</span> <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fillfactor = </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">with_params</span></div>


<div class="viewcode-block" id="GinIndex"><a class="viewcode-back" href="../../../../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.GinIndex">[docs]</a><span class="k">class</span> <span class="nc">GinIndex</span><span class="p">(</span><span class="n">PostgresIndex</span><span class="p">):</span>
    <span class="n">suffix</span> <span class="o">=</span> <span class="s1">&#39;gin&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">fastupdate</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">gin_pending_list_limit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fastupdate</span> <span class="o">=</span> <span class="n">fastupdate</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">gin_pending_list_limit</span> <span class="o">=</span> <span class="n">gin_pending_list_limit</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">deconstruct</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">deconstruct</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fastupdate</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;fastupdate&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fastupdate</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">gin_pending_list_limit</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;gin_pending_list_limit&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">gin_pending_list_limit</span>
        <span class="k">return</span> <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span>

    <span class="k">def</span> <span class="nf">check_supported</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schema_editor</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">gin_pending_list_limit</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">schema_editor</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">features</span><span class="o">.</span><span class="n">has_gin_pending_list_limit</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">NotSupportedError</span><span class="p">(</span><span class="s1">&#39;GIN option gin_pending_list_limit requires PostgreSQL 9.5+.&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">gin_pending_list_limit</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;gin_pending_list_limit = </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">gin_pending_list_limit</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fastupdate</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fastupdate = </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="s1">&#39;on&#39;</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fastupdate</span> <span class="k">else</span> <span class="s1">&#39;off&#39;</span><span class="p">))</span>
        <span class="k">return</span> <span class="n">with_params</span></div>


<div class="viewcode-block" id="GistIndex"><a class="viewcode-back" href="../../../../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.GistIndex">[docs]</a><span class="k">class</span> <span class="nc">GistIndex</span><span class="p">(</span><span class="n">PostgresIndex</span><span class="p">):</span>
    <span class="n">suffix</span> <span class="o">=</span> <span class="s1">&#39;gist&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">buffering</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">fillfactor</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">buffering</span> <span class="o">=</span> <span class="n">buffering</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="o">=</span> <span class="n">fillfactor</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">deconstruct</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">deconstruct</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffering</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;buffering&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffering</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;fillfactor&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span>
        <span class="k">return</span> <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffering</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;buffering = </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="s1">&#39;on&#39;</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">buffering</span> <span class="k">else</span> <span class="s1">&#39;off&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fillfactor = </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">with_params</span></div>


<div class="viewcode-block" id="HashIndex"><a class="viewcode-back" href="../../../../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.HashIndex">[docs]</a><span class="k">class</span> <span class="nc">HashIndex</span><span class="p">(</span><span class="n">PostgresIndex</span><span class="p">):</span>
    <span class="n">suffix</span> <span class="o">=</span> <span class="s1">&#39;hash&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">fillfactor</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="o">=</span> <span class="n">fillfactor</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">deconstruct</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">deconstruct</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;fillfactor&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span>
        <span class="k">return</span> <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fillfactor = </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">with_params</span></div>


<div class="viewcode-block" id="SpGistIndex"><a class="viewcode-back" href="../../../../ref/contrib/postgres/indexes.html#django.contrib.postgres.indexes.SpGistIndex">[docs]</a><span class="k">class</span> <span class="nc">SpGistIndex</span><span class="p">(</span><span class="n">PostgresIndex</span><span class="p">):</span>
    <span class="n">suffix</span> <span class="o">=</span> <span class="s1">&#39;spgist&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">fillfactor</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="o">=</span> <span class="n">fillfactor</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">deconstruct</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">deconstruct</span><span class="p">()</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">kwargs</span><span class="p">[</span><span class="s1">&#39;fillfactor&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span>
        <span class="k">return</span> <span class="n">path</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span>

    <span class="k">def</span> <span class="nf">get_with_params</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">with_params</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">with_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;fillfactor = </span><span class="si">%d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">fillfactor</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">with_params</span></div>
</pre></div>

          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 04, 2020</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    <a href="../../../index.html" title="Module code" accesskey="U">up</a></div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>